package com.sense.kukoo.biz_media.vm

import androidx.lifecycle.MutableLiveData
import com.sense.kukoo.common.media.Kukoo
import com.sense.kukoo.common.mvvm.model.BaseMvvmModel
import com.sense.kukoo.common.mvvm.vm.BaseViewModel
import com.sense.kukoo.common.repo.bean.*

class MediaListViewModel: BaseViewModel() {

    private val TAG: String = javaClass.simpleName

    val action_back: MutableLiveData<Boolean> = MutableLiveData()
    val action_showCleanAllDialog: MutableLiveData<Boolean> = MutableLiveData()
    val data_playListData:MutableLiveData<ArrayList<MediaItemBean>> = MutableLiveData()

    override fun createModel(): BaseMvvmModel? = null

    override fun initData() {}

    fun onBack(){
        action_back.postValue(true)
    }

    fun onCleanAllClick(){
        action_showCleanAllDialog.postValue(true)
    }

    fun refreshPlayListData(){
        request {
            val data = arrayListOf<MediaItemBean>()
            val list = Kukoo.playlist.getList()
            list.forEach {
                data.add(MediaItemBean(data = it))
            }
            data_playListData.postValue(data)
        }
    }

}